<?php
class Createlistmodel extends CI_Model {
 
        
    function put($dat){
		echo $dat;
		$data = array();
		$data['name'] = $this->input->get('listname');
		$data['list'] = $dat;
		
		$this->db->insert('ssrt5_turnirlist', $data); 
	}
	
	function mod($dat){
		echo $dat;
		$data = array();
		$data['name'] = $this->input->get('turname');
		$data['date'] = $this->input->get('date');
		$data['type'] = $this->input->get('type');
		$data['descr'] = $this->input->get('text');
		$data['form'] = $dat;
		$this->db->where('id', $this->input->get('idtur'));
		$this->db->update('ssrt5_turnirs', $data); 
	}
	
	function drop($id){
		 $this->db->delete('ssrt5_turnirlist', array('id' => $id)); 
	}
	
	function getlist()
	{
		$query = $this->db->query("SELECT id, name FROM ssrt5_turnirlist"); 
				
		return $query->result();
	}
	
	function getlistone()
	{
		$id = (int)$this->input->get('id');
		$query = $this->db->query("SELECT list FROM ssrt5_turnirlist WHERE id='$id'"); 
				
		return $query->result();
	}
	
	function putlistone($dat, $id){
		$data = array();
		$data['list'] = $dat;
		
		$this->db->where('id', $id);
		$this->db->update('ssrt5_turnirlist', $data); 
	}
}
?>
